<style lang="less">
  .card_style {
    height: 100%;
    width: 100%;
    overflow: hidden;
    .ivu-card-body {
      padding: 0px;
    }
  }
  .page_style {
    margin-top: 10px;
    text-align: right;
  }
  .bench_search {
    margin-bottom: 10px;
  }
  .mr5 {
    margin-right: 5px;
  }
  .nopadding .ivu-table-cell {
    padding: 0px 0px;
  }
  .fenye {
    margin-top: 20px;
    display: flex;
    flex-direction: row-reverse;
  }
  .new-btn-sty {
    margin-right: 5px;
    color: #fff;
    background-color: #235CA7;
    border-color: #235CA7;
    font-weight: 500;
  }
</style>
<template>
  <Card class="card_style" :bordered="false" :dis-hover="true">
    <Tabs :animated="false" @on-click="clickTabs" v-model="tabIndex">
      <TabPane label="事项设置" name="item_setting">
        <Row class="bench_search">
          <Col span="6">
            <span>业务编号：</span>
            <Input style="width: 70%;" v-model="searchInfo.item_code"/>
          </Col>
          <Col span="6" offset="1">
            <span>事项名称：</span>
            <Input style="width: 70%;" v-model="searchInfo.ql_name"/>
          </Col>
          <Button class="new-btn-sty" @click="searchData(1)">
            <Icon type="ios-search"/> 搜索
          </Button>
        </Row>
        <Table border :columns="columns1" :data="datalist">
          <template slot-scope="{ row }" slot="item_name">
            <span>{{ row.ql_name }}</span><br/>
            <span>{{ row.item_code }}</span>
          </template>
          <template slot-scope="{ row }" slot="belong_name">
            <span>{{ row.type_name }}</span><br/>
            <span>{{ row.org_code }}</span>
          </template>
          <template slot-scope="{ row }" slot="bl_type">
            <span>{{ compareDict[row.service_type] }}</span>
          </template>
          <template slot-scope="{ row }" slot="is_show">
            <Tag v-if="row.del_falg == '0'" color="green">显示</Tag>
            <Tag v-else color="red">隐藏</Tag>
          </template>
          <template slot-scope="{ row }" slot="buttons">
            <Button type="primary" class="mr5" size="small" @click="itemEdit(row)">编辑</Button>
            <Button type="primary" class="mr5" v-show="row.service_type!='fun'" size="small" @click="itemEditDoc(row)">编辑要件</Button>
            <Button type="info" class="mr5" v-show="row.fileurl" size="small" @click="showPDF(row.file_url)">PDF</Button>
            <Button type="info" v-show="row.fileurl" size="small" @click="showPDF(row.form_url)">表单</Button>
            <Button type="error"  size="small" @click="feiqi(row)">废弃</Button>
          </template>
        </Table>
        <Page :total="totalnum" :current="currentPageNo" :page-size="currentPageSize" @on-change="searchData" class="page_style"/>
        <Modal v-model="setModal1" title="文档" width="800">
          <Form label-position="right">
            <Row>
              <Col span="24" class="ivu-form-item-content" style="text-align: center">
                <embed width="750" v-show="setModal1" height="600" :src="itemPDF"></embed>
              </Col>
            </Row>
          </Form>
          <div slot="footer">
            <Button type="error" @click="setModal1=false">关闭</Button>
          </div>
        </Modal>
        <Modal v-model="setModal2" title="事项编辑" width="700" cancel-text="关闭" ok-text="确定"
               @on-ok="saveEdit" @on-cancel="setModal2=false">
          <Form :ref="paramData" :model="paramData">
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">归属机构：</Col>
              <Col span="12" class="ivu-form-item-content">{{paramData.type_name}}（{{paramData.org_code}}）</Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">事项名称：</Col>
              <Col span="12" class="ivu-form-item-content">
                <Input v-model="paramData.ql_name" :disabled="paramData.audit_state=='40'"></Input>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">事项编号：</Col>
              <Col span="12" class="ivu-form-item-content">
                <Input v-model="paramData.item_code" disabled></Input>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">办事类型：</Col>
              <Col span="12">
                <Select v-model="paramData.service_type" style="width:200px">
                  <Option value="general">通办</Option>
                  <Option value="internet">网办</Option>
                  <Option value="seal">盖章证明</Option>
                  <Option value="fun">功能按钮</Option>
                </Select>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">流程组ID：</Col>
              <Col span="12">
                <Select v-model="paramData.process_group_id">
                  <Option value="0">0-无任务流转功能事项</Option>
                  <Option value="3">3-常规办理流程无对接</Option>
                  <Option value="4">4-盖章证明办理流程</Option>
                  <Option value="5">5-常规办理流程数据推送至营商</Option>
                </Select>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">interface_code：</Col>
              <Col span="12">
                <Input v-model="paramData.interface_code"></Input>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">上传表单文档：</Col>
              <Col span="5">
                <Upload action="//txy.juyouhx.com/Api/Api/ObjectToOss/" :format="['pdf','jpg','jpeg','png','doc','docx']"
                :max-size="10240" :on-format-error="handleFormatError" :on-exceeded-size="handleMaxSize"
                style="display: inline-block" :on-success="uploadFile">
                  <Button icon="ios-cloud-upload-outline">上传</Button>
                </Upload>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">表单文档路径：</Col>
              <Col span="15" class="ivu-form-item-content">
                <Input v-model="paramData.form_url" type="textarea" :autosize="{minRows: 1,maxRows: 4}"></Input>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">上传PDF文档：</Col>
              <Col span="5">
                <Upload action="//txy.juyouhx.com/Api/Api/ObjectToOss/" :format="['pdf','jpg','jpeg','png','doc','docx']"
                :max-size="10240" :on-format-error="handleFormatError" :on-exceeded-size="handleMaxSize"
                style="display: inline-block" :on-success="uploadFile1">
                  <Button icon="ios-cloud-upload-outline">上传</Button>
                </Upload>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">PDF文档路径：</Col>
              <Col span="15" class="ivu-form-item-content">
                <Input v-model="paramData.file_url" type="textarea" :autosize="{minRows: 1,maxRows: 4}"></Input>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">排序：</Col>
              <Col span="12">
                <InputNumber v-model="paramData.sort"></InputNumber>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">是否营商审核：</Col>
              <Col span="12" class="ivu-form-item-content">
                <RadioGroup v-model="paramData.is_approval" type="button">
                  <Radio label="1">是</Radio>
                  <Radio label="0">否</Radio>
                </RadioGroup>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">可否网上办理：</Col>
              <Col span="12" class="ivu-form-item-content">
                <RadioGroup v-model="paramData.is_wsbl" type="button">
                  <Radio label="1">是</Radio>
                  <Radio label="0">否</Radio>
                </RadioGroup>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">办理订单可否删除：</Col>
              <Col span="12" class="ivu-form-item-content">
                <RadioGroup v-model="paramData.is_wsbl" type="button">
                  <Radio label="1">可以</Radio>
                  <Radio label="0">不可以</Radio>
                </RadioGroup>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">是否显示：</Col>
              <Col span="12" class="ivu-form-item-content">
                <RadioGroup v-model="paramData.del_falg" type="button">
                  <Radio label="0">显示</Radio>
                  <Radio label="1">不显示</Radio>
                </RadioGroup>
              </Col>
            </Row>
            <Row class="bench_search">
              <Col span="7" class="ivu-form-item-label">显示位置：</Col>
              <Col span="12" class="ivu-form-item-content">
                <CheckboxGroup v-model="paramData.showState">
                  <Checkbox label="pc">PC端</Checkbox>
                  <Checkbox label="app">手机端</Checkbox>
                </CheckboxGroup>
              </Col>
            </Row>
          </Form>
        </Modal>
        <Modal v-model="setModal3" title="事项要件列表" width="1000">
          <Table border :columns="itemdocTable" :data="paramData.itemdocList">
            <template slot-scope="{ row }" slot="doc_name">
              <span v-if="!row.update">{{row.name}}</span>
              <Input v-else v-model="row.name"></Input>
            </template>
            <template slot-scope="{ row }" slot="necessary">
              <div v-if="!row.update">
                <Tag v-if="row.necessary == '1'" :fade="false" color="green">是</Tag>
                <Tag v-else color="red" :fade="false">否</Tag>
              </div>
              <div v-else>
                <Select v-model="row.necessary" :transfer="true">
                  <Option value="1">是</Option>
                  <Option value="0">否</Option>
                </Select>
              </div>
            </template>
            <template slot-scope="{ row }" slot="write_type">
              <div v-if="!row.update">
                <span v-if="row.write_type == 'images'">图片要件</span>
                <span v-if="row.write_type == 'form'">表单</span>
              </div>
              <div v-else>
                <Select v-model="row.write_type" :transfer="true">
                  <Option value="images">图片要件</Option>
                  <Option value="form">表单</Option>
                </Select>
              </div>
            </template>
            <template slot-scope="{ row }" slot="isarchivesinfo">
              <span v-if="row.isarchivesinfo == '1'">是</span>
              <span v-else>否</span>
            </template>
            <template slot-scope="{ row }" slot="asort">
              <span v-if="!row.update">{{row.asort}}</span>
              <Input v-else v-model="row.asort"></Input>
            </template>
            <template slot-scope="{ row }" slot="form_path">
              <span v-if="!row.update">{{row.form_path}}</span>
              <Input v-else v-model="row.form_path"></Input>
            </template>
            <template slot-scope="{ row, index }" slot="buttons">
              <div v-show="row.isarchivesinfo=='0'">
                <Button type="primary" class="mr5" size="small" v-show="!row.update" @click="turnState(row,index)">修改</Button>
                <Button type="primary" class="mr5" size="small" v-show="row.update" @click="turnState(row,index)">确认</Button>
                <Button type="error" size="small" @click="delItemDoc(index)">删除</Button>
              </div>
            </template>
          </Table>
          <div slot="footer">
            <Button type="primary" @click="addItemDoc">添加要件</Button>
            <Button type="primary" @click="updateItemDoc">确定</Button>
            <Button type="error" @click="setModal3=false">关闭</Button>
          </div>
        </Modal>
      </TabPane>
      <TabPane label="电子证照更新" name="dzzz_setting">
        <Row class="bench_search">
          <Col span="6">
            <span>社区账号：</span>
            <Input style="width: 70%;" v-model="searchInfo.company_code1"/>
          </Col>
          <Col span="6" offset="1">
            <span>社区名称：</span>
            <Input style="width: 70%;" v-model="searchInfo.sqmc1"/>
          </Col>
          <Button class="new-btn-sty" @click="searchData1">
            <Icon type="ios-search"/> 搜索
          </Button>
        </Row>
        <Table border :columns="columns2" :data="datalist2">
          <template slot-scope="{ row }" slot="dzzz_name">
            <span>{{ row.company_code }}</span>
            <span v-if="row.company_name">（{{ row.company_name }}）</span>
          </template>
          <template slot-scope="{ row }" slot="template_info">
            <span>{{ row.template_name }}</span><br/>
            <span>{{ row.template_id }}</span>
          </template>
          <template slot-scope="{ row }" slot="buttons">
            <Button type="primary" size="small" @click="settingModal(row, 'visaModal')">更新</Button>
          </template>
        </Table>
        <Modal v-model="modalDate.visaModal" title="配置社区电子证照" width="500" cancel-text="关闭" ok-text="确定"
               @on-ok="updateVisaInfo(modalDate)" @on-cancel="modalDate.visaModal=false">
          <Form :model="modalDate">
            <Row>
              <Col span="7" class="ivu-form-item-label">社区账号：</Col>
              <Col span="12" class="ivu-form-item-content">
                <Input v-model="modalDate.company_code"></Input>
              </Col>
            </Row>
          </Form>
        </Modal>
      </TabPane>
      <TabPane label="配置医保账号" name="yb_setting">
        <Row class="bench_search">
          <Col span="6">
            <span>社区账号：</span>
            <Input style="width: 70%;" v-model="searchInfo.company_code2"/>
          </Col>
          <Col span="6" offset="1">
            <span>社区名称：</span>
            <Input style="width: 70%;" v-model="searchInfo.sqmc2"/>
          </Col>
          <Button class="new-btn-sty" @click="searchData2">
            <Icon type="ios-search"/> 搜索
          </Button>
        </Row>
        <Table border :columns="columns3" :data="datalist3">
          <template slot-scope="{ row }" slot="yibao_name">
            <span>{{ row.company_code }}</span>
            <span v-if="row.company_name">（{{ row.company_name }}）</span>
          </template>
          <template slot-scope="{ row }" slot="buttons">
            <Button type="primary" size="small" @click="settingModal(row, 'yibaoModal')">更新</Button>
          </template>
        </Table>
        <Modal v-model="modalDate.yibaoModal" title="配置医保账号" width="500" cancel-text="关闭" ok-text="确定"
               @on-ok="updateYibaoInfo(modalDate)" @on-cancel="modalDate.yibaoModal=false">
          <Form :model="modalDate">
            <Row>
              <Col span="7" class="ivu-form-item-label">社区账号：</Col>
              <Col span="12" class="ivu-form-item-content">
                <Input v-model="modalDate.company_code"></Input>
              </Col>
            </Row>
          </Form>
        </Modal>
      </TabPane>
      <TabPane label="配置人社账号" name="rs_setting">
        <Row class="bench_search">
          <Col span="6">
            <span>社区账号：</span>
            <Input style="width: 70%;" v-model="searchInfo.company_code3"/>
          </Col>
          <Col span="6" offset="1">
            <span>社区名称：</span>
            <Input style="width: 70%;" v-model="searchInfo.sqmc3"/>
          </Col>
          <Button class="new-btn-sty" @click="searchData4">
            <Icon type="ios-search"/> 搜索
          </Button>
        </Row>
        <Table border :columns="columns5" :data="datalist5">
          <template slot-scope="{ row }" slot="renshe_name">
            <span>{{ row.company_code }}</span>
            <span v-if="row.company_name">（{{ row.company_name }}）</span>
          </template>
          <template slot-scope="{ row }" slot="buttons">
            <Button type="primary" size="small" @click="settingModal(row, 'rensheModal')">更新</Button>
          </template>
        </Table>
        <Modal v-model="modalDate.rensheModal" title="配置人社账号" width="500" cancel-text="关闭" ok-text="确定"
               @on-ok="updateRensheInfo(modalDate)" @on-cancel="modalDate.rensheModal=false">
          <Form :model="modalDate">
            <Row>
              <Col span="7" class="ivu-form-item-label">社区账号：</Col>
              <Col span="12" class="ivu-form-item-content">
                <Input v-model="modalDate.company_code"></Input>
              </Col>
            </Row>
          </Form>
        </Modal>
      </TabPane>
      <TabPane label="事项更新" name="item_update">
        <Row class="bench_search">
          <Col span="6">
            <span>事项名称：</span>
            <Input style="width: 70%;" v-model="searchInfo.ql_name3"/>
          </Col>
          <Button class="new-btn-sty" @click="searchData3">
            <Icon type="ios-search"/> 搜索
          </Button>
        </Row>
        <Table border :columns="columns4" :data="datalist4">
          <template slot-scope="{ row }" slot="item_name">
            <span v-if="row.item_code">{{ row.ql_name }}</span>
            <span v-else>{{ row.ql_name_new }}</span>
          </template>
          <template slot-scope="{ row }" slot="buttons">
            <Button type="info" size="small" class="mr5" @click="itemInfoCompare(row)">事项对比</Button>
            <Button type="primary" v-show="row.item_code" size="small" @click="updateItemInfo(row,false)">更新</Button>
            <Button type="success" v-show="!row.item_code" size="small" @click="updateItemInfo(row,false)">添加</Button>
          </template>
        </Table>
        <Modal v-model="itemupdateModal" title="事项信息对比" width="1000">
          <Table :columns="columnsCompare" :data="itemInfoAll">
            <template slot-scope="{ row }" slot="compareNew">
              <span v-if="typeof row.new === 'object'">
                <p v-for="item in row.new" v-bind:key="item.name">
                  {{item.name}}({{item.necessary=='1'?'必填':'非必填'}})
                </p>
              </span>
              <span v-else>{{ row.new }}</span>
            </template>
            <template slot-scope="{ row }" slot="compareOld">
              <span v-if="typeof row.old === 'object'">
                <p v-for="item in row.old" v-bind:key="item.name">
                  {{item.name}}({{item.necessary=='1'?'必填':'非必填'}})
                </p>
              </span>
              <span v-else>{{ row.old }}</span>
            </template>
          </Table>
          <div slot="footer">
            <Button type="success" @click="updateItemInfo(itemInfoAll, true)">更新</Button>
            <Button type="error" @click="itemupdateModal=false">关闭</Button>
          </div>
        </Modal>
      </TabPane>
      <TabPane label="配置房产租赁账号" name="fc_setting">
        <Row class="bench_search">
          <Col span="6">
            <span>社区账号：</span>
            <Input style="width: 70%;" v-model="searchInfo.company_code6"/>
          </Col>
          <Col span="6" offset="1">
            <span>社区名称：</span>
            <Input style="width: 70%;" v-model="searchInfo.desc16"/>
          </Col>
          <Button class="new-btn-sty" @click="searchData6(1)">
            <Icon type="ios-search"/> 搜索
          </Button>
        </Row>
        <Table border :columns="columns6" :data="datalist6">
          <template slot-scope="{ row }" slot="fangchan_name">
            <span>{{ row.company_code }}</span>
            <span v-if="row.company_name">（{{ row.company_name }}）</span>
          </template>
          <template slot-scope="{ row }" slot="buttons">
            <Button type="primary" size="small" @click="settingModal(row, 'fangchanModal')">更新</Button>
          </template>
        </Table>
        <Page :total="totalnum" :current="currentPageNo" :page-size="currentPageSize"
              @on-change="searchData6" class="page_style"/>
        <Modal v-model="modalDate.fangchanModal" title="配置房产租赁账号" width="500" cancel-text="关闭" ok-text="确定"
               @on-ok="updateFangchanInfo(modalDate)" @on-cancel="modalDate.fangchanModal=false">
          <Form :model="modalDate">
            <Row>
              <Col span="7" class="ivu-form-item-label">社区账号：</Col>
              <Col span="12" class="ivu-form-item-content">
                <Input v-model="modalDate.company_code"></Input>
              </Col>
            </Row>
          </Form>
        </Modal>
      </TabPane>
    </Tabs>
  </Card>
</template>
<script>
import { itemList, saveItem, updateItemDoc, visalist, updateVisa, yibaoList, itemParamByOrderList,
  itemUpdateList, getItemUpdateInfo, updateItem, rensheList, updateRenshe, updateYibao,
  delFeiqi, fczhulinList, updateFczhulin } from '@/api/eventlist'

export default {
  data () {
    return {
      tabIndex: 0,
      setModal1: false,
      setModal2: false,
      setModal3: false,
      itemupdateModal: false,
      // 事项配置的pdf链接
      itemPDF: '',
      searchInfo: {},
      // 电子证照|医保|人社 配置账号时弹出框信息
      modalDate: { visaModal: false, yibaoModal: false, rensheModal: false, fangchanModal: false },
      // 事项信息配置
      paramData: { itemdocList: [] },
      totalnum: 0,
      currentPageNo: 1,
      currentPageSize: 10,
      columns1: [
        { title: '序号', type: 'index', width: 70, align: 'center' },
        { title: '事项名称', slot: 'item_name' },
        { title: '归属机构', slot: 'belong_name', width: 200 },
        { title: '办事类型', slot: 'bl_type', width: 150, align: 'center' },
        { title: '是否显示', slot: 'is_show', width: 130, align: 'center' },
        { title: '操作', align: 'center', slot: 'buttons', className: 'nopadding', width: 220 }
      ],
      columns2: [
        { title: '序号', type: 'index', width: 70, align: 'center' },
        { title: '社区账号', slot: 'dzzz_name', align: 'center' },
        { title: '模板信息', slot: 'template_info', width: 260, align: 'center' },
        { title: '社区名称', key: 'issue_unitname', width: 200, align: 'center' },
        { title: '操作', align: 'center', slot: 'buttons', width: 170 }
      ],
      columns3: [
        { title: '序号', type: 'index', width: 70, align: 'center' },
        { title: '社区账号', slot: 'yibao_name', align: 'center' },
        { title: '社区名称', key: 'sqmc', width: 230, align: 'center' },
        { title: '单位编号', key: 'dwbh', width: 220, align: 'center' },
        { title: '操作', align: 'center', slot: 'buttons', width: 170 }
      ],
      columns5: [
        { title: '序号', type: 'index', width: 70, align: 'center' },
        { title: '社区账号', slot: 'renshe_name', align: 'center' },
        { title: '社区名称', key: 'sqmc', width: 230, align: 'center' },
        { title: '单位编号', key: 'dwbh', width: 220, align: 'center' },
        { title: '操作', align: 'center', slot: 'buttons', width: 170 }
      ],
      columns6: [
        { title: '序号', type: 'index', width: 70, align: 'center' },
        { title: '社区账号', slot: 'fangchan_name', align: 'center' },
        { title: '社区名称', key: 'desc1', width: 230, align: 'center' },
        { title: '用户名称', key: 'username', width: 220, align: 'center' },
        { title: '操作', align: 'center', slot: 'buttons', width: 170 }
      ],
      columns4: [
        { title: '序号', type: 'index', width: 70, align: 'center' },
        { title: '事项名称', slot: 'item_name' },
        { title: '事项编号', key: 'item_code_new', width: 260, align: 'center' },
        { title: '最新版本', key: 'version_new', width: 100, align: 'center' },
        { title: '获取时间', key: 'create_time', width: 170, align: 'center' },
        { title: '操作', align: 'center', slot: 'buttons', width: 170 }
      ],
      columnsCompare: [
        { title: '新信息', slot: 'compareNew', align: 'right' },
        { title: '对比值', key: 'key', width: 100, align: 'center' },
        { title: '原信息', slot: 'compareOld', align: 'left' }
      ],
      itemdocTable: [
        { title: '要件名称', slot: 'doc_name', minWidth: 200 },
        { title: '必填项', slot: 'necessary', align: 'center', width: 90 },
        { title: '要件类型', slot: 'write_type', align: 'center', width: 100 },
        { title: '营商要件', slot: 'isarchivesinfo', align: 'center', width: 90 },
        { title: '排序', slot: 'asort', align: 'center', width: 80 },
        { title: 'form_path', slot: 'form_path', align: 'center', width: 200 },
        { title: '操作', align: 'center', className: 'nopadding', slot: 'buttons', width: 130 }
      ],
      compareDict: {
        'a1': '是',
        'a0': '否',
        'state1': '在用',
        'state2': '暂停',
        'state3': '取消',
        'blxs1': '窗口办理',
        'blxs2': '网上办理',
        'blxs3': '快递申请',
        'general': '通办',
        'internet': '网办',
        'seal': '盖章证明',
        'fun': '功能按钮'
      },
      datalist: [],
      datalist2: [],
      datalist3: [],
      datalist4: [],
      datalist5: [],
      datalist6: [],
      itemInfoAll: []
    }
  },
  methods: {
    feiqi (row) {
      if (confirm('是否废弃？')) {
        let chanshu = { item_code: row.item_code, del_falg: '1' }
        delFeiqi(chanshu).then(res => {
          if (res.data.errcode === 0) {
            this.$Notice.success({ title: '废弃成功', desc: '' })
            this.searchData(this.currentPageNo)
          } else {
            this.$Notice.error({ title: '废弃失败', desc: '' })
          }
        })
      }
    },
    clickTabs (name) {
      if (name === 'item_update') {
        this.searchData3()
      }
    },
    showPDF (url) {
      this.itemPDF = url
      this.setModal1 = true
    },
    // 事项信息配置数据列表
    searchData (pageNo) {
      let param = {
        item_code: this.searchInfo.item_code,
        ql_name: this.searchInfo.ql_name,
        pageNo: pageNo,
        pageSize: this.currentPageSize
      }
      itemList(param).then(res => {
        if (res.data.errcode === 0) {
          this.datalist = res.data.data.results
          this.totalnum = res.data.data.totalRecord
        } else {
          this.$Notice.error({ title: '获取事项列表失败', desc: res.data.errmsg })
        }
      })
    },
    // 电子证照数据列表
    searchData1 () {
      let param = {
        company_code: this.searchInfo.company_code1,
        issue_unitname: this.searchInfo.sqmc1
      }
      visalist(param).then(res => {
        if (res.data.errcode === 0) {
          this.datalist2 = res.data.data
        } else {
          this.$Notice.error({ title: '获取电子证照列表失败', desc: res.data.errmsg })
        }
      })
    },
    // 配置医保账号
    searchData2 () {
      let param = {
        company_code: this.searchInfo.company_code2,
        sqmc: this.searchInfo.sqmc2
      }
      yibaoList(param).then(res => {
        if (res.data.errcode === 0) {
          this.datalist3 = res.data.data
        } else {
          this.$Notice.error({ title: '获取社区列表失败', desc: res.data.errmsg })
        }
      })
    },
    // 配置人社账号
    searchData4 () {
      let param = {
        company_code: this.searchInfo.company_code3,
        sqmc: this.searchInfo.sqmc3
      }
      rensheList(param).then(res => {
        if (res.data.errcode === 0) {
          this.datalist5 = res.data.data
        } else {
          this.$Notice.error({ title: '获取社区列表失败', desc: res.data.errmsg })
        }
      })
    },
    // 配置房产租赁账号
    searchData6 (pageNo) {
      let param = {
        company_code: this.searchInfo.company_code6,
        desc1: this.searchInfo.desc16,
        pageNo: pageNo,
        pageSize: this.currentPageSize
      }
      fczhulinList(param).then(res => {
        if (res.data.errcode === 0) {
          this.datalist6 = res.data.data.results
          this.totalnum = res.data.data.totalRecord
        } else {
          this.$Notice.error({ title: '获取房产租赁列表失败', desc: res.data.errmsg })
        }
      })
    },
    // 事项更新列表
    searchData3 () {
      itemUpdateList({ name: this.searchInfo.ql_name3 }).then(res => {
        if (res.data.errcode === 0) {
          this.datalist4 = res.data.data
        } else {
          this.$Notice.error({ title: '加载事项更新列表失败', desc: res.data.errmsg })
        }
      })
    },
    // 显示电子证照|医保|人社模态框
    settingModal (obj, modal) {
      this.modalDate.company_code = ''
      this.modalDate.id = obj.id
      this.modalDate[modal] = true
    },
    itemInfoCompare (obj) {
      let param = {
        item_code: obj.item_code_new,
        version: obj.version_new
      }
      this.itemupdateModal = true
      getItemUpdateInfo(param).then(res => {
        if (res.data.errcode === 0) {
          this.itemInfoAll = []
          let temp = res.data.data
          this.itemInfoAll.push({ id: 0, key: '名称', new: temp.ql_name, old: temp.ql_name_old })
          this.itemInfoAll.push({ id: 1, key: '编号', new: temp.item_code, old: temp.item_code_old })
          this.itemInfoAll.push({ id: 2, key: '事项ID', new: obj.item_id, old: temp.item_id_old })
          this.itemInfoAll.push({ id: 3, key: '版本', new: temp.version, old: temp.version_old })
          this.itemInfoAll.push({ id: 4, key: '事项状态', new: this.compareDict['state' + temp.ql_state], old: this.compareDict['state' + temp.ql_state_old] })
          this.itemInfoAll.push({ id: 5, key: '是否收费', new: this.compareDict['a' + temp.charge_flag], old: this.compareDict['a' + temp.charge_flag_old] })
          this.itemInfoAll.push({ id: 6, key: '受理机构', new: temp.sljg, old: temp.sljg_old })
          this.itemInfoAll.push({ id: 7, key: '办理形式', new: this.compareDict['blxs' + temp.blxs], old: this.compareDict['blxs' + temp.blxs_old] })
          this.itemInfoAll.push({ id: 8, key: '咨询方式', new: temp.link_tel, old: temp.link_tel_old })
          this.itemInfoAll.push({ id: 9, key: '办理地址', new: temp.accept_address, old: temp.accept_address_old })
          this.itemInfoAll.push({ id: 10, key: '工作时间', new: temp.accept_time, old: temp.accept_time_old })
          this.itemInfoAll.push({ id: 11, key: '受理条件', new: temp.apply_condition, old: temp.apply_condition_old })
          this.itemInfoAll.push({
            id: 12,
            key: '承诺时限',
            new: temp.promise_day === -1 ? '即办件' : temp.promise_day + '个工作日',
            old: temp.promise_day_old ? temp.promise_day_old === -1 ? '即办件' : temp.promise_day_old + '个工作日' : null
          })
          this.itemInfoAll.push({ id: 13, key: '时限说明', new: temp.sxsm, old: temp.sxsm_old })
          this.itemInfoAll.push({ id: 14, key: '要件', new: temp.docmentnew, old: temp.docmentold })
        } else {
          this.$Notice.error({ title: '失败', desc: res.data.errmsg })
        }
      })
    },
    uploadFile (res) {
      this.paramData.form_url = res.url
    },
    uploadFile1 (res) {
      this.paramData.file_url = res.url
    },
    // 文件格式
    handleFormatError (file) {
      this.$Notice.warning({
        title: '文件格式错误',
        desc: '文件 ' + file.name + ' 不正确，请选择pdf、png、jpg、doc格式文件'
      })
    },
    // 文件大小
    handleMaxSize (file) {
      this.$Notice.warning({
        title: '文件大小超出限制',
        desc: '文件  ' + file.name + ' 不能超过10M。'
      })
    },
    saveEdit () {
      this.paramData.show_state = this.paramData.showState.toString()
      saveItem(this.paramData).then(res => {
        if (res.data === 'success') {
          this.$Notice.success({ title: '修改成功', desc: '' })
          this.searchData(this.currentPageNo)
        } else {
          this.$Notice.error({ title: '修改失败', desc: res.data.errmsg })
        }
      })
    },
    itemEdit (item) {
      this.paramData.ql_name = item.ql_name
      this.paramData.item_code = item.item_code
      this.paramData.type_name = item.type_name
      this.paramData.org_code = item.org_code
      this.paramData.service_type = item.service_type
      this.paramData.process_group_id = item.process_group_id
      this.paramData.del_falg = item.del_falg
      this.paramData.is_approval = item.is_approval
      this.paramData.is_wsbl = item.is_wsbl
      this.paramData.order_del_flag = item.order_del_flag
      this.paramData.sort = item.sort
      this.paramData.file_url = item.file_url
      this.paramData.form_url = item.form_url
      this.paramData.audit_state = item.audit_state
      this.paramData.interface_code = item.interface_code
      this.paramData.showState = item.show_state.split(',')
      this.setModal2 = true
    },
    itemEditDoc (item) {
      this.setModal3 = true
      this.paramData.item_code = item.item_code
      this.paramData.itemdocList = []
      itemParamByOrderList({ id: item.item_code }).then(res => {
        if (res.data.errcode === 0) {
          res.data.data.forEach(element => {
            element.update = false
            this.paramData.itemdocList.push(element)
          })
        } else {
          this.$Notice.error({ title: '查询要件失败', desc: res.data.errmsg })
        }
      })
    },
    addItemDoc () {
      let temp = {
        document_id: '-',
        isarchivesinfo: '0',
        necessary: '1',
        write_type: 'form',
        asort: 10,
        update: true
      }
      this.paramData.itemdocList.push(temp)
    },
    turnState (row, index) {
      let temp = this.paramData.itemdocList[index]
      if (temp.update && !row.name) {
        this.$Notice.warning({ title: '错误', desc: '请填写要件名称' })
        return
      }
      temp.name = row.name
      temp.asort = row.asort
      temp.necessary = row.necessary
      temp.write_type = row.write_type
      temp.form_path = row.form_path
      temp.update = !temp.update
    },
    delItemDoc (index) {
      this.paramData.itemdocList.splice(index, 1)
    },
    updateItemDoc () {
      let param = {
        item_code: this.paramData.item_code,
        list: []
      }
      this.paramData.itemdocList.forEach(element => {
        if (element.isarchivesinfo === '0') {
          if (element.name) {
            element.type = element.write_type === 'form' ? 'form' : 'file'
            element.ordernumber = element.asort
            param.list.push(element)
          } else {
            this.$Notice.warning({ title: '错误', desc: '名称未填写的要件无法添加' })
          }
        }
      })
      updateItemDoc(param).then(res => {
        if (res.data.errcode === 0) {
          this.$Notice.success({ title: '成功', desc: '事项自定义要件设置成功' })
          this.setModal3 = false
        } else {
          this.$Notice.error({ title: '失败', desc: res.data.errmsg })
        }
      })
    },
    // 配置电子证照账号
    updateVisaInfo (item) {
      if (!item.company_code) {
        this.$Notice.warning({ title: '错误', desc: '请填写社区编号' })
        return
      }
      var param = {
        id: item.id,
        company_code: item.company_code
      }
      updateVisa(param).then(res => {
        if (res.data.errcode === 0) {
          this.$Notice.success({ title: '成功', desc: '更新电子证照成功' })
        } else {
          this.$Notice.error({ title: '失败', desc: res.data.errmsg
          })
        }
      })
    },
    // 配置医保账号
    updateYibaoInfo (item) {
      if (!item.company_code) {
        this.$Notice.warning({ title: '错误', desc: '请填写社区编号' })
        return
      }
      var param = {
        id: item.id,
        company_code: item.company_code
      }
      updateYibao(param).then(res => {
        if (res.data.errcode === 0) {
          this.$Notice.success({ title: '成功', desc: '医保账号配置成功' })
        } else {
          this.$Notice.error({ title: '失败', desc: res.data.errmsg })
        }
      })
    },
    // 配置人社账号
    updateRensheInfo (item) {
      if (!item.company_code) {
        this.$Notice.warning({ title: '错误', desc: '请填写社区编号' })
        return
      }
      var param = {
        id: item.id,
        company_code: item.company_code
      }
      updateRenshe(param).then(res => {
        if (res.data.errcode === 0) {
          this.$Notice.success({ title: '成功', desc: '人社账号配置成功' })
          this.searchData4()
        } else {
          this.$Notice.error({ title: '失败', desc: res.data.errmsg })
        }
      })
    },
    // 配置房产租赁账号
    updateFangchanInfo (item) {
      if (!item.company_code) {
        this.$Notice.warning({ title: '错误', desc: '请填写社区编号' })
        return
      }
      var param = {
        id: item.id,
        company_code: item.company_code
      }
      updateFczhulin(param).then(res => {
        if (res.data.errcode === 0) {
          this.$Notice.success({ title: '成功', desc: '房产租赁账号配置成功' })
          this.searchData6()
        } else {
          this.$Notice.error({ title: '失败', desc: res.data.errmsg })
        }
      })
    },
    // 事项更新，seeInfo=true对比事项信息后更新事项，seeInfo=false未对比更新
    updateItemInfo (obj, seeInfo) {
      let para = {}
      if (seeInfo) {
        para.item_code = obj[1].new
        para.item_id = obj[2].new
        para.version = obj[3].new
      } else {
        para.item_code = obj.item_code_new
        para.version = obj.version_new
        para.item_id = obj.item_id
      }
      updateItem(para).then(res => {
        if (res.data.errcode === 0) {
          this.$Notice.success({ title: '成功', desc: '事项更新成功' })
          this.searchData3()
        } else {
          this.$Notice.error({ title: '失败', desc: res.data.errmsg })
        }
      })
    }
  },
  mounted () {
    this.searchData(1)
  }
}
</script>
